// room script file

function room_AfterFadeIn()
{
  StartCutscene(eSkipESCOnly);
  
  player.Say("Welcome to Demo 2.");
  player.Say("I'll introduce you to Character tweens and other intermediate effects.");
  
  player.Say("There are three tween types for a character: Position, Scaling, and Transparency.");
  player.Say("From the previous demo, you should be familiar with Position and Transparency, and Scaling works the same way.");
  
  player.TweenScaling(2.0, 5, eEaseOutTween); // Scale player in 2 seconds to 5% and ease out.
  player.TweenScaling(2.0, 200, eEaseInEaseOutTween); // Scale player in 2 seconds to 200% and ease in and out.
  
  player.Say("That was fun!");
  player.Say("Now I'll show you one of the powers of using the Tween module, which is tweening things without blocking.");
  
  player.TweenScaling(1.0, 100, eEaseOutTween);
  
  player.Say("Let's say you want to tween my position without blocking and then have me say something.");
  player.Say("What you need to do is use a timer. All non-blocking Tweens return how long (in game loops) they are going to take.");
  player.Say("So, here I go, I will tween without blocking and say something:");
 
  // Every non-blocking tween function returns the number of cycles it's going to take.
  // This way, you can do things like these. You could also use Wait() and make it blocking.
  SetTimer(1, player.TweenPosition(2.5, 160, 199, eEaseOutTween, eNoBlockTween));
}
  
function room_RepExec()
{
  if (IsTimerExpired(1))
  {
    player.Say("I just moved without blocking and waited to say this!");
    
    player.Say("Now, we can make this more complicated.");
    player.Say("I can tween my position, scale, and transparency at the same time, non-blocking, and say something.");
    player.Say("Here we go:");
    
    float duration = 2.5;
    player.TweenTransparency(duration, 100, eEaseOutTween, eNoBlockTween);
    player.TweenScaling(duration, 5, eEaseOutTween, eNoBlockTween);
    SetTimer(2, player.TweenPosition(duration, 160, 100, eEaseInEaseOutTween, eNoBlockTween));
    // Alternatively, you could code it like this:
    // player.TweenPosition(duration, 160, 100, eEaseInEaseOutTween, eNoBlockTween);
    // SetTimer(2, SecondsToLoops(duration));
  }
  
  if (IsTimerExpired(2))
  {
    player.Say("I'm invisible!");
    
    float duration = 2.5;
    player.TweenTransparency(duration, 0, eEaseOutTween, eNoBlockTween);
    player.TweenScaling(duration, 100, eEaseOutTween);
    
    player.Say("See? That was easy.");
    player.Say("Hopefully, you're thinking about what you can do with this kind of power.");
    player.Say("Demo 3 might give you a taste of that.");
    
    Wait(SecondsToLoops(2.0));
    
    EndCutscene();
    player.ChangeRoom(3);
  }
}
